<template>
  <div>
    <div v-if="isShowTabs" class="links">
      <div v-for="(item, index) in routeNames" :key="index" class="linkItem">
        <router-link :to="{ name: item.name }">
          {{ item.label }}
        </router-link>
      </div>
    </div>
    <router-view />
  </div>
</template>

<script>
export default {
  data() {
    return {
      routeNames: [
        { label: 'Images', name: 'MaterialImages' },
        { label: 'Design', name: 'MaterialDesign' }
      ]
    };
  },
  computed: {
    isShowTabs: function() {
      return this.routeNames.findIndex(item => item.name === this.$route.name) > -1;
    }
  }
};
</script>

<style scoped lang="scss">
.links {
  position: relative;
  &:after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: #e4e7ed;
    z-index: 1;
  }
  .linkItem {
    padding: 0 20px;
    height: 40px;
    box-sizing: border-box;
    line-height: 40px;
    display: inline-block;
    list-style: none;
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    position: relative;
    .router-link-active {
      display: block;
      position: relative;
      color: #16AD61;
      &:after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 2px;
        background-color: #16AD61;
        z-index: 2;
      }
    }
  }
}
</style>
